---
title: convert
description: Create a Dinero object converter.
returns: Dinero<TAmount>
---

Convert a Dinero object from a currency to another.

If you need to use fractional rates, you shouldn't use floats, but scaled amounts instead. For example, instead of passing `0.89`, you should pass `{ amount: 89, scale: 2 }`. When using scaled amounts, the function converts the returned object to the safest scale.

## Parameters

<Parameters>

<Parameter name="dineroObject" type="Dinero<TAmount>" required={true}>

The Dinero object to convert.

</Parameter>

<Parameter name="newCurrency" type="Currency<TAmount>" required={true}>

The currency to convert into.

</Parameter>

<Parameter name="rates" type="Rates<TAmount>" required={true}>

The rates to convert with.

</Parameter>

</Parameters>

## Code examples

### Convert to another currency

```js
import { dinero, convert } from 'dinero.js';
import { USD, EUR } from '@dinero.js/currencies';

const rates = { EUR: { amount: 89, scale: 2 } };
const d = dinero({ amount: 500, currency: USD });

convert(d, EUR, rates); // a Dinero object with amount 44500 and scale 4
```

### Convert to a currency with a different scale

```js
import { dinero, convert } from 'dinero.js';
import { USD, IQD } from '@dinero.js/currencies';

const rates = { IQD: 1199 };
const d = dinero({ amount: 500, currency: USD });

convert(d, IQD, rates); // a Dinero object with amount 5995000 and scale 3
```

### Build a reusable converter

If you're converting many objects, you might want to reuse the same rates without having to pass them every time. To do so, you can wrap `convert` in a converter function that accepts a Dinero object and a new currency, and returns it formatted using a predefined converter.

```js
import { dinero, convert } from 'dinero.js';
import { USD, EUR } from '@dinero.js/currencies';

function converter(dineroObject, newCurrency) {
  return convert(dineroObject, newCurrency, { EUR: { amount: 89, scale: 2 } });
}

const converter = createConverter(rates);

converter(d, EUR); // a Dinero object with amount 44500 and scale 4
```

You can even build your own reusable higher-order function to build converters.

```js
// ...

function createConverter(rates) {
  return function converter(dineroObject, newCurrency) {
    return convert(dineroObject, newCurrency, rates);
  };
}
```
